using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChuangTouGui2:MonoBehaviour {

	[SerializeField] DialougeClip dialougeLocked;
	[SerializeField] DialougeClip dialougeUnlocking;
	[SerializeField] DialougeClip dialougeUnlocked;

	[SerializeField] GameObject woShiYaoShiPrefab;

	[SerializeField] string yuanKongYaoShiName;
	void OnInteraction() {
		InteractionTarget interactable = GetComponent<InteractionTarget>();
		if(interactable.flag==0) {

			if(PlayerController.instance.IsHolding(yuanKongYaoShiName)) {
				PlayerController.instance.RemoveItem(yuanKongYaoShiName);
				VNController.instance.EnterDialouge(
					dialougeUnlocking,
					() => {
						PlayerController.instance.AddToInventoryFromPrefab(woShiYaoShiPrefab);
						interactable.flag=1;
					}
				);
			} else {
				VNController.instance.EnterDialouge(dialougeLocked);
			}

		} else {
			VNController.instance.EnterDialouge(dialougeUnlocked);
		}
	}

}
